package com.yzy.fly.mapper;

import com.yzy.fly.entity.core.FlyClass;
import com.yzy.fly.kernel.mapper.FlyBasicMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Collection;
import java.util.List;


@Mapper
public interface FlyClassMapper extends FlyBasicMapper<FlyClass> {

    @Select("select * from fly_class a where 1=1")
    List<FlyClass> selectAll();

    @Select("select * from fly_class a where 1=1 and a.systemId = #{systemId}")
    List<FlyClass> selectAllBySystemId(@Param("systemId") int systemId);

    @Select("select * from fly_class a where 1=1 and a.id = (select b.classId from fly_field b where b.id = #{fieldId})")
    FlyClass selectOneByFieldId(@Param("fieldId") int fieldId);

    @Select("select * from fly_class a where 1=1 and a.name = #{name}")
    FlyClass selectOneByName(@Param("name") String name);

    /**
     * 批量插入（mysql）
     * @param entityList
     * @return
     */
    Integer insertBatchSomeColumn(Collection<FlyClass> entityList);

    @Select("select * from fly_class a where systemId = 0 order by a.packageName asc")
    List<FlyClass> selectAllPackageNameAsc();
    //TODO
//    select distinct a.packageName from fly_class a where systemId = 0 order by a.packageName asc;
}